layui.config({
    base: "/js/modules/"
}).extend({
    "listView": "listView"
});
layui.use(['form', 'listView', 'laydate', 'jquery', 'common', 'table'], function () {
    let layDate = layui.laydate,
        form = layui.form,
        common = layui.common,
        layer = layui.layer,
        table = layui.table,
        $ = layui.$;

    layDate.render(
        {
            elem: "#beginTime", trigger: 'click', type: 'datetime'
        }
    );
    layDate.render(
        {
            elem: "#endTime", trigger: 'click', type: 'datetime'
        }
    );

    layui.listView.tableInit({
        id: 'typeData',
        url: '/device/type/data/page',
        page: true,
        cols: [
            {field: 'number', title: '序号', fixed: 'true', type: 'numbers'},
            {field: 'id', title: '编号'},
            {field: 'name', title: '名称'},
            {field: 'unit', title: '单位'},
            {field: 'typeName', title: '类型'}
        ]
    });

    $('#addTypeData').on('click', function () {
        layer.open({
            title: '新增设备信息',
            type: 2,
            area: ['400px', '500px'],
            fixed: false, //不固定
            maxmin: true,
            content: '/device/toAddTypeData'
        });
    });


    //操作
    table.on('tool(deviceInfo)', function (obj) {
        var data = obj.data;
        // console.log(obj.data)
        if (obj.event === 'edit') {
            layer.alert('编辑行：<br>' + JSON.stringify(data))
            layer.open({
                title: '编辑设备信息',
                type: 2,
                area: ['400px', '500px'],
                fixed: false, //不固定
                maxmin: true,
                content: '/device/info/queryDeviceInfo?id=' + data.id
            });
        }
    });

});
